package com.rainng.coursesystem.common;

import lombok.Data;

@Data
public class Result {
//    后端返回
    private int code;//编码：200/400
    private String msg;//成功/失败
    private Long total;//总记录数
    private Object data;//数据

    public static com.rainng.coursesystem.common.Result fail(){
        return result(400,"失败",0L,null);
    }
    public static com.rainng.coursesystem.common.Result suc(){
        return result(200,"成功",0L,null);
    }

    public static com.rainng.coursesystem.common.Result suc(Object data){
        return result(200,"成功",0L,data);
    }

    public static com.rainng.coursesystem.common.Result suc(Object data, Long total){
        return result(200,"成功",total,data);
    }

    private static com.rainng.coursesystem.common.Result result(int code, String msg, Long total, Object data){
        com.rainng.coursesystem.common.Result res = new com.rainng.coursesystem.common.Result();
        res.setData(data);
        res.setMsg(msg);
        res.setCode(code);
        res.setTotal(total);
        return res;
    }
}
